import { ICategoryData } from '@/api/category/type';
import { http } from '@/core/http';

export const getCategoryList = (params?: {
    categoryName?: string;
    categoryCode?: string;
    pageSize?: number;
    pageNum?: number;
}) => {
  return http.get<ICategoryData>({
    url: 'admin/category/list',
    isLoading: false,
    params
  });
};

/**
 * 新增分类
 * @param data
 */
export const categoryCreate = (data: {
    categoryName: string;
    categoryCode: string;
    description?: string;
}) => {
  return http.post({
    url: 'admin/category/add',
    isLoading: false,
    isShowSuccessText: true,
    data
  });
};

/**
 * 更新分类
 * @param data
 */
export const categoryUpdate = (data: {
    categoryName: string;
    categoryCode: string;
    description?: string;
    categoryId: number;
}) => {
  return http.put({
    url: 'admin/category/update',
    isLoading: false,
    isShowSuccessText: true,
    data
  });
};
